using System;
using System.IO;
using System.Xml;
using System.Reflection;
using System.Collections.Generic;

namespace ECCIT.Configuration
{
	/// <summary>
	/// 
	/// </summary>
	[Serializable]
	public class ConfigCacheManager
	{
        public static Dictionary<string, string> AssemblyTypeMappingDictionary = GetAssemblyTypeMappingDictionary ();

        public static Dictionary<string, string> GetAssemblyTypeMappingDictionary()
        {
            string executingPath = AppDomain.CurrentDomain.RelativeSearchPath;
            string[] dlls = Directory.GetFiles (executingPath, "*.dll");
            Dictionary<string, string> dic = new Dictionary<string, string> ();
            Dictionary<string,string> duplicateDict = new Dictionary<string,string>();
            foreach (string dll in dlls)
            {
                Assembly assembly = Assembly.LoadFile (dll);
                Type[] types = assembly.GetTypes ();

                foreach (Type type in types)
                {
                    if (!dic.ContainsKey (type.FullName))
                    {
                        dic.Add (type.FullName, dll);
                    }
                    else
                    {
                        if (!duplicateDict.ContainsKey (type.FullName))
                            duplicateDict.Add (type.FullName, dll);
                    }
                }
            }

            return dic;
        }

	}
}
